<?php

namespace app\admin\model\shop;

use think\Model;


class Shoplist extends Model
{





    // 表名
    protected $name = 'shoplist';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text',
        'spell_status_text',
        'smallimages_domain'
    ];



    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
    }

    public function getSpellStatusList()
    {
        return ['0' => __('Spell_status 0'), '1' => __('Spell_status 1')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

//    public function getSmallimagesAttr($value, $data){
//        $value =   explode(',',$value);
//        foreach ($value as $k=>$v){
//            $value[$k] = request()->domain().$v;
//        }
//        return implode($value,',');
//    }
    public function getSmallimagesDomainAttr($value, $data){
       return get_img_domain($data['smallimages']);
    }

    public function getSpellStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['spell_status']) ? $data['spell_status'] : '');
        $list = $this->getSpellStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
